import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
/* angular的路由模块 */
import { RouterModule } from '@angular/router';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { HttpClientModule,HttpClient } from '@angular/common/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
/* 第三方模块 */
import { UEditorModule } from 'ngx-ueditor';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
/* 自定义的路由模块 */
import { AppRoutingModule } from './app.routing';
/* 根页面 */
import { AppComponent } from './app.component';
/* 其他页面 */
import { Echart01Component } from './../modules/views/echart01/echart01.component';
import { Echart02Component } from './../modules/views/echart02/echart02.component';
import { Echart03Component } from './../modules/views/echart03/echart03.component';
import { Ueditor01Component } from './../modules/views/ueditor01/ueditor01.component';
import { GoJS01Component } from './../modules/views/gojs01/gojs01.component';
import { Translate01Component } from './../modules/views/translate01/translate01.component';
import { GoJS02Component } from './../modules/views/gojs02/gojs02.component';
/* 服务 */
import { GetEchartDataService } from './../modules/services/get-echart-data.service';
/* 自定义组件 */
import { RoundLoadingComponent } from './../modules/common/round-loading/round.loading.component';
import { RoundToggleButtonComponent } from './../modules/common/round-toggle-button/round.toggle.button.component';
import { FreeEnumPipe } from './../modules/services/freeEnum/free-enum.pipe';
import { HtmlPipe } from './../modules/views/ueditor01/html-pipe';
import { DiagramEditorComponent } from './../modules/common/diagram-editor/diagram-editor.component';
import { CustomDiagramEditorComponent} from './../modules/common/custom-diagram-editor/custom-diagram-editor.component';

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
@NgModule({
  // 声明组件
  declarations: [
    AppComponent,
    Echart01Component,
    Echart02Component,
    Echart03Component,
    RoundLoadingComponent,
    RoundToggleButtonComponent,
    FreeEnumPipe,
    Ueditor01Component,
    HtmlPipe,
    GoJS01Component,
    DiagramEditorComponent,
    Translate01Component,
    CustomDiagramEditorComponent,
    GoJS02Component
  ],
  // 引用模块
  imports: [
    BrowserModule,
    RouterModule,
    FormsModule,
    ReactiveFormsModule,
    HttpModule,
    HttpClientModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    UEditorModule.forRoot({
      js: [
        './../assets/ueditor/ueditor.all.js',
        './../assets/ueditor/ueditor.config.js'
      ],
      // 默认前端配置项
      options: {
        UEDITOR_HOME_URL: './../assets/ueditor/'
      }
    }),
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient]
      }
    })
  ],
  // 导出angular的路由模块
  exports: [
    RouterModule
  ],
  providers: [
    GetEchartDataService,
    HttpClient
  ],
  // 根（启动）页面
  bootstrap: [AppComponent]
})
export class AppModule { }
